//
//  InMemoryBitmap.h
//  ToneMapper
//
//  Created by Andrey on 03/02/2009.
//  Copyright 2009 Karma Software. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#define HISTOGRAM_STEP_COUNT 256

typedef struct _BitmapPixel 
{
	CGFloat red;
	CGFloat green;
	CGFloat blue;
	CGFloat alpha;
	CGFloat luminance;
} BitmapPixel;

@interface InMemoryBitmap : NSObject 
{
	NSUInteger height;
	NSUInteger width;
	
	BitmapPixel* pixelData;
	CGFloat _scalingFactor;
	CGFloat _clampingLuminance;
	
	// Statistics
	CGFloat maxLuminance;
	CGFloat minLuminance;
	Boolean needRecomputeHistogram;
	int* histogram;
}

@property (readonly) NSUInteger height;
@property (readonly) NSUInteger width;
@property (readonly) BitmapPixel* pixelData;

- (id) init;
- (id) initWithFile: (NSString*)url;
- (id) initWithOpenExrFile: (NSString*)filename;
- (id) initWithWidth: (NSUInteger)w AndHeight: (NSUInteger)h;
- (id) initWithBitmap: (InMemoryBitmap*) bitmap;
- (BitmapPixel) getPixelAtX: (NSUInteger)x Y: (NSUInteger)y;
- (void) setPixelTo: (BitmapPixel)pixel AtX: (NSUInteger)x Y: (NSUInteger)y;
- (void) multiplyPixels: (InMemoryBitmap*) bitmap;
- (void) scalePixels: (CGFloat)factor;
- (void) clampPixels: (CGFloat)clampingIntensity;
- (int*) getHistogram;
- (void) dealloc;

@end
